/**
 * 业务表维护
 * 
 * @class
 * @extends Ext.Panel
 */
var Buis = new Ext.extend(Ext.Panel, {
	border : false,
	layout : 'border',
	sql : "SELECT * FROM ( SELECT A.*, ROWNUM RN FROM (select B_VOU_ID,EN_ID,EN_CODE,EN_NAME,BS_ID,BS_CODE,BS_NAME,MB_ID,MB_CODE,MB_NAME,MK_ID,MK_CODE,MK_NAME,BL_ID,BL_CODE,BL_NAME,HOLD1_ID,HOLD1_CODE,HOLD1_NAME,BIS_ID,BIS_CODE,BIS_NAME,BI_ID,BI_CODE,BI_NAME,PK_ID,PK_CODE,PK_NAME,HOLD2_ID,HOLD2_CODE,HOLD2_NAME,HOLD3_ID,HOLD3_CODE,HOLD3_NAME,HOLD15_ID,HOLD15_CODE,HOLD15_NAME,BP_ID,BP_CODE,BP_NAME,FILE_NAME,SM_NAME,REMARK,TITLE,BUDGETTYPE_CODE,TYPE_ID,ADJUST_WAY,IS_VALID,IS_END,BUDGET_GROUPID,BA_CODE,BA_NAME,TOCTRLID,FROMCTRLID,BUDGET_MONEY-MINUS_MONEY SHOW_MONEY, BUDGET_MONEY,DELETED,CREATE_DATE,COPYID,MINUS_MONEY,(select count(1) from ele_budget_syncdata where deleted=0 and copyid=t.b_vou_id) subitems from ele_budget_syncdata t where DELETED=0 AND BUDGET_MONEY - MINUS_MONEY > 0 {where} order by en_code,bs_code,budget_money-minus_money) A WHERE ROWNUM <= #{start}+#{limit} ) WHERE RN >= #{start}+1 ",
	totalSql : "select nvl(sum(budget_money-minus_money),0) SHOW_MONEY from ele_budget_syncdata where deleted=0 {where}",
	countSql : "select count(1) from ele_budget_syncdata where DELETED=0 AND BUDGET_MONEY - MINUS_MONEY > 0 {where}",
	initComponent : function() {
		this.initQuery();
		this.initGrid();
		this.items = [this.query, this.grid];
		Buis.superclass.initComponent.call(this);
	},
	exportExcel : function() {
		var store = this.grid.getStore();
		if (store.getCount() == 0) {
			My.alert('当前没有数据，不能执行导出!');
			return;
		}
		var form = new Ext.form.FormPanel({
					border : false,
					padding : 5,
					labelWidth : 70,
					standardSubmit : true,
					baseParams : {
						sql : store.baseParams.totalSql,
						totalSql : store.baseParams.totalSql,
						exceltpl : 'ec70a5d7-07f4-41e5-8f89-551acd92ae27',
						name : '业务数据_' + (new Date().format('Y-m-d')),
						datacols : 'budget_money',
						excelstart : '2'
					},
					url : My.url('/system/common/export2Excel.htm'),
					items : []
				});
		/**
		 * 导出excel
		 */
		var exportExcel = function() {
			if (!form.getForm().isValid()) {
				My.alert('您输入的页数不对，请检查');
				return;
			}
			if (form.baseParams && !form.paramsAdded) {
				for (i in form.baseParams) {
					form.add({
								xtype : 'hidden',
								name : i,
								value : form.baseParams[i]
							});
				}
				form.doLayout();
				form.paramsAdded = true;
			}
			form.getForm().submit();
		};
		new Ext.Window({
					title : '导出Excel',
					width : 300,
					autoHeight : true,
					modal : true,
					items : [form]
				}).show(false, function(w) {
					exportExcel();
					w.close();
				});
	},
	search : function() {
		var values = this.query.getForm().getValues();
		var where = "";
		for (var field in values) {
			var value = values[field];
			if (field == 'copyid') {
				if (value == '1') {
					where += " and copyid is not null";
				} else if (value == '0') {
					where += " and copyid is null";
				}
				continue;
			}
			if (value) {
				if (value.indexOf(',') > 0) {
					where += " and " + field + " in('"
							+ value.replace(/,/g, "','") + "')";
				} else {
					var isLike = false;
					if (field.indexOf('@') == 0) {
						isLike = true;
						field = field.substr(1, field.length - 1);
					}
					if (isLike) {
						where += " and " + field + " like '%" + value + "%'";
					} else {
						where += " and " + field + "='" + value + "'";
					}
				}
			}
		}
		var store = this.grid.getStore();
		store.baseParams.sql = this.sql.replace("{where}", where);
		store.baseParams.countSql = this.countSql.replace("{where}", where);
		store.baseParams.totalSql = this.totalSql.replace("{where}", where);
		store.load();
	},
	sync : function() {
		var me = this;
		My.confirm("确定要同步业务数据吗？", function(btn) {
					if (btn == 'no') {
						return;
					}
					My.request({
								url : My
										.url('/system/database/fixbase/syncBuis.do'),
								timeout : 30 * 60 * 1000,
								successCallback : function() {
									me.grid.getStore().reload();
								}
							});
				});
	},
	del : function() {
		var me = this;
		var rec = this.grid.getRecord();
		if (!rec) {
			TopMy.alert('请选择要删除的业务数据！');
			return;
		}
		if (rec.data.subitems > 0) {
			TopMy.confirm('该数据被拆分过，如果继续删除则拆分后的数据也会被删除？', function(btn) {
				if (btn == 'no') {
					return;
				}
				My.request({
							url : My
									.url('/system/database/fixbase/deleteBuis.do'),
							params : {
								b_vou_id : rec.data.b_vou_id
							},
							successCallback : function() {
								me.grid.getStore().reload();
							}
						});
			});
		} else {
			TopMy.confirm('确定要删除该业务数据吗？', function(btn) {
				if (btn == 'no') {
					return;
				}
				My.request({
							url : My
									.url('/system/database/fixbase/deleteBuis.do'),
							params : {
								b_vou_id : rec.data.b_vou_id
							},
							successCallback : function() {
								me.grid.getStore().reload();
							}
						});
			});
		}
	},
	chaifen : function() {
		var me = this;
		var rec = this.grid.getRecord();
		if (!rec) {
			TopMy.alert('请选择要拆分的业务数据！');
			return;
		}
		if (!rec.data.en_name || rec.data.en_name == '合计') {
			return;
		}
		if (rec.data.adjust_way != '1') {
			TopMy.alert('该数据不能拆分！');
			return;
		}
		var form = new TopExt.FormPanel({
					border : false,
					autoScroll : true,
					padding : 5,
					layout : 'column',
					defaults : {
						border : false,
						columnWidth : .5,
						defaults : {
							xtype : 'textfield',
							anchor : '100%',
							allowBlank : false
						},
						labelWidth : 110,
						labelAlign : 'right',
						layout : 'form'
					},
					items : [{
						items : [{
							xtype : 'supercombotree',
							fieldLabel : '预算单位',
							name : 'en_code',
							"table" : "ele_enterprise",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '业务科室',
							name : 'mb_code',
							"table" : "ele_manage_branch",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '预算来源',
							name : 'bl_code',
							"table" : "ELE_BUDGET_LABEL",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '项目名称',
							name : 'bis_code',
							"table" : "ELE_BUDGET_ITEM_SUMMARY",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '支付方式',
							name : 'pk_code',
							"table" : "ele_payoff_kind",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '编制类型',
							name : 'hold3_code',
							"table" : "ELE_HOLD3",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '指标类型',
							name : 'bp_code',
							"table" : "ELE_BUDGET_PURPOSE",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							fieldLabel : '资金用途',
							name : 'sm_name'
						}, {
							xtype : 'numberfield',
							fieldLabel : '指标金额',
							name : 'budget_money',
							maxValue : rec.data.show_money
						}]
					}, {
						items : [{
							xtype : 'supercombotree',
							fieldLabel : '功能分类',
							name : 'bs_code',
							"table" : "ele_budget_subject",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '资金性质',
							name : 'mk_code',
							"table" : "ELE_MONEY_KIND",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '预算来源性质',
							name : 'hold1_code',
							"table" : "ELE_HOLD1",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '项目分类',
							name : 'bi_code',
							"table" : "ELE_BUDGET_ITEM",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '政府支出管理结构',
							name : 'hold2_code',
							"table" : " ELE_HOLD2",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '涉农标识',
							name : 'hold15_code',
							"table" : "ELE_HOLD15",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = form.getForm().findField(before
										+ '_id');
								var name = form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							fieldLabel : '指标文号',
							name : 'file_name'
						}, {
							fieldLabel : '指标标题',
							name : 'title',
							allowBlank : true
						}, {
							fieldLabel : '自定义编号',
							name : 'remark',
							allowBlank : true
						}, {
							xtype : 'hidden',
							name : 'b_vou_id'
						}, {
							xtype : 'hidden',
							name : 'en_id'
						}, {
							xtype : 'hidden',
							name : 'bs_id'
						}, {
							xtype : 'hidden',
							name : 'mb_id'
						}, {
							xtype : 'hidden',
							name : 'mk_id'
						}, {
							xtype : 'hidden',
							name : 'bl_id'
						}, {
							xtype : 'hidden',
							name : 'hold1_id'
						}, {
							xtype : 'hidden',
							name : 'bis_id'
						}, {
							xtype : 'hidden',
							name : 'bi_id'
						}, {
							xtype : 'hidden',
							name : 'pk_id'
						}, {
							xtype : 'hidden',
							name : 'hold2_id'
						}, {
							xtype : 'hidden',
							name : 'hold3_id'
						}, {
							xtype : 'hidden',
							name : 'hold15_id'
						}, {
							xtype : 'hidden',
							name : 'bp_id'
						}, {
							xtype : 'hidden',
							name : 'en_name'
						}, {
							xtype : 'hidden',
							name : 'bs_name'
						}, {
							xtype : 'hidden',
							name : 'mb_name'
						}, {
							xtype : 'hidden',
							name : 'mk_name'
						}, {
							xtype : 'hidden',
							name : 'bl_name'
						}, {
							xtype : 'hidden',
							name : 'hold1_name'
						}, {
							xtype : 'hidden',
							name : 'bis_name'
						}, {
							xtype : 'hidden',
							name : 'bi_name'
						}, {
							xtype : 'hidden',
							name : 'pk_name'
						}, {
							xtype : 'hidden',
							name : 'hold2_name'
						}, {
							xtype : 'hidden',
							name : 'hold3_name'
						}, {
							xtype : 'hidden',
							name : 'hold15_name'
						}, {
							xtype : 'hidden',
							name : 'bp_name'
						}]
					}],
					listeners : {
						afterrender : function(t) {
							t.getForm().loadRecord(rec);
							t.getForm().findField('budget_money')
									.setValue(rec.data.show_money);
						}
					}
				});
		var win = new TopExt.Window({
			title : '拆分业务数据 -> ' + rec.data.en_name + '-' + rec.data.bs_name
					+ '-' + rec.data.budget_money,
			width : 800,
			autoHeight : true,
			modal : true,
			items : [form],
			buttons : [{
				text : '保存',
				iconCls : 'icon-save',
				handler : function() {
					var budget_money = form.getForm().findField('budget_money')
							.getValue();
					if (!budget_money || budget_money < 0) {
						TopMy.alert('指标金额不能小于0！');
						return;
					}
					if (budget_money > rec.data.show_money) {
						TopMy.alert('指标金额不能大于' + rec.data.show_money + '！');
						return;
					}
					var url = My.url('/system/database/fixbase/chaifenBuis.do');
					TopMy.submit(form, {
								url : url,
								params : {
									copyid : rec.data.b_vou_id
								},
								successCallback : function() {
									win.close();
									me.grid.getStore().reload();
								}
							});
				}
			}, {
				text : '取消',
				iconCls : 'icon-cancel',
				handler : function() {
					win.close();
				}
			}]
		});
		win.show();
	},
	update : function() {
		var me = this;
		if (this.win) {
			this.win.close();
		}
		var rec = this.grid.getRecord();
		if (!rec) {
			TopMy.alert('请选择要修改的业务数据！');
			return;
		}
		if (!rec.data.en_name || rec.data.en_name == '合计') {
			return;
		}
		if (rec.data.copyid) {
			TopMy.alert('拆分的数据不能修改，可将其删除后重新拆分！');
			return;
		}
		this.form = new TopExt.FormPanel({
					border : false,
					autoScroll : true,
					padding : 5,
					layout : 'column',
					defaults : {
						border : false,
						columnWidth : .5,
						defaults : {
							xtype : 'textfield',
							anchor : '100%',
							allowBlank : false
						},
						labelWidth : 110,
						labelAlign : 'right',
						layout : 'form'
					},
					items : [{
						items : [{
							xtype : 'supercombotree',
							fieldLabel : '预算单位',
							name : 'en_code',
							"table" : "ele_enterprise",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '业务科室',
							name : 'mb_code',
							"table" : "ele_manage_branch",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '预算来源',
							name : 'bl_code',
							"table" : "ELE_BUDGET_LABEL",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							fieldLabel : '项目名称',
							name : 'bis_name',
							allowBlank : false
						}/*
							 * { xtype : 'supercombotree', fieldLabel : '项目名称',
							 * name : 'bis_code', "table" :
							 * "ELE_BUDGET_ITEM_SUMMARY", "displayField" :
							 * "chr_name", "valueField" : "chr_code",
							 * "parentField" : "parent_id", "idField" :
							 * "chr_id", "leafField" : "is_leaf", "selectMode" :
							 * "leaf", "multi" : false, "rootValue" : "all",
							 * joinCode : true, setDataCallback : function(v,
							 * text, node) { if (!node) { return; } var before =
							 * this.name.split('_')[0]; var code =
							 * me.form.getForm().findField(before + '_id'); var
							 * name = me.form.getForm().findField(before +
							 * '_name'); if (node.attributes.chr_id) {
							 * code.setValue(node.attributes.chr_id);
							 * name.setValue(node.attributes.chr_name); } } }
							 */, {
							xtype : 'supercombotree',
							fieldLabel : '支付方式',
							name : 'pk_code',
							"table" : "ele_payoff_kind",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '编制类型',
							name : 'hold3_code',
							"table" : "ELE_HOLD3",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '指标类型',
							name : 'bp_code',
							"table" : "ELE_BUDGET_PURPOSE",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							fieldLabel : '资金用途',
							name : 'sm_name'
						}, {
							fieldLabel : '指标金额',
							name : 'budget_money'
						}]
					}, {
						items : [{
							xtype : 'supercombotree',
							fieldLabel : '功能分类',
							name : 'bs_code',
							"table" : "ele_budget_subject",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '资金性质',
							name : 'mk_code',
							"table" : "ELE_MONEY_KIND",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '预算来源性质',
							name : 'hold1_code',
							"table" : "ELE_HOLD1",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '项目分类',
							name : 'bi_code',
							"table" : "ELE_BUDGET_ITEM",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '政府支出管理结构',
							name : 'hold2_code',
							"table" : " ELE_HOLD2",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							xtype : 'supercombotree',
							fieldLabel : '涉农标识',
							name : 'hold15_code',
							"table" : "ELE_HOLD15",
							"displayField" : "chr_name",
							"valueField" : "chr_code",
							"parentField" : "parent_id",
							"idField" : "chr_id",
							"leafField" : "is_leaf",
							"selectMode" : "leaf",
							"multi" : false,
							"rootValue" : "all",
							joinCode : true,
							setDataCallback : function(v, text, node) {
								if (!node) {
									return;
								}
								var before = this.name.split('_')[0];
								var code = me.form.getForm().findField(before
										+ '_id');
								var name = me.form.getForm().findField(before
										+ '_name');
								if (node.attributes.chr_id) {
									code.setValue(node.attributes.chr_id);
									name.setValue(node.attributes.chr_name);
								}
							}
						}, {
							fieldLabel : '指标文号',
							name : 'file_name'
						}, {
							fieldLabel : '指标标题',
							name : 'title',
							allowBlank : true
						}, {
							fieldLabel : '自定义编号',
							name : 'remark',
							allowBlank : true
						}, {
							xtype : 'hidden',
							name : 'b_vou_id'
						}, {
							xtype : 'hidden',
							name : 'en_id'
						}, {
							xtype : 'hidden',
							name : 'bs_id'
						}, {
							xtype : 'hidden',
							name : 'mb_id'
						}, {
							xtype : 'hidden',
							name : 'mk_id'
						}, {
							xtype : 'hidden',
							name : 'bl_id'
						}, {
							xtype : 'hidden',
							name : 'hold1_id'
						}, {
							xtype : 'hidden',
							name : 'bis_id'
						}, {
							xtype : 'hidden',
							name : 'bi_id'
						}, {
							xtype : 'hidden',
							name : 'pk_id'
						}, {
							xtype : 'hidden',
							name : 'hold2_id'
						}, {
							xtype : 'hidden',
							name : 'hold3_id'
						}, {
							xtype : 'hidden',
							name : 'hold15_id'
						}, {
							xtype : 'hidden',
							name : 'bp_id'
						}, {
							xtype : 'hidden',
							name : 'en_name'
						}, {
							xtype : 'hidden',
							name : 'bs_name'
						}, {
							xtype : 'hidden',
							name : 'mb_name'
						}, {
							xtype : 'hidden',
							name : 'mk_name'
						}, {
							xtype : 'hidden',
							name : 'bl_name'
						}, {
							xtype : 'hidden',
							name : 'hold1_name'
						}, {
							xtype : 'hidden',
							name : 'bis_code'
						}, {
							xtype : 'hidden',
							name : 'bi_name'
						}, {
							xtype : 'hidden',
							name : 'pk_name'
						}, {
							xtype : 'hidden',
							name : 'hold2_name'
						}, {
							xtype : 'hidden',
							name : 'hold3_name'
						}, {
							xtype : 'hidden',
							name : 'hold15_name'
						}, {
							xtype : 'hidden',
							name : 'bp_name'
						}]
					}],
					listeners : {
						afterrender : function(t) {
							t.getForm().loadRecord(rec);
						}
					}
				});
		this.win = new TopExt.Window({
					title : '修改业务数据 -> ' + rec.data.en_name + '-'
							+ rec.data.bs_name + '-' + rec.data.budget_money,
					width : 800,
					autoHeight : true,
					modal : true,
					items : [this.form],
					buttons : [{
						text : '保存',
						iconCls : 'icon-save',
						handler : function() {
							var budget_money = me.form.getForm()
									.findField('budget_money').getValue();
							var minus_money = rec.data.minus_money;
							if (!budget_money || budget_money < minus_money) {
								TopMy.alert('该指标已调减金额为' + minus_money
										+ '，修改金额不能小于' + minus_money + '！');
								return;
							}
							var url = My
									.url('/system/database/fixbase/updateBuis.do');
							TopMy.submit(me.form, {
										url : url,
										successCallback : function() {
											me.win.close();
											me.grid.getStore().reload();
										}
									});
						}
					}, {
						text : '取消',
						iconCls : 'icon-cancel',
						handler : function() {
							me.win.close();
						}
					}]
				});
		this.win.show();
		return this.form;
	},
	initQuery : function() {
		this.query = new Ext.FormPanel({
			region : 'north',
			height : 135,
			padding : 5,
			layout : 'column',
			border : false,
			defaults : {
				border : false,
				columnWidth : .4,
				layout : 'form',
				labelAlign : 'right',
				defaults : {
					xtype : 'textfield',
					anchor : '100%'
				}
			},
			items : [{
						items : [{
									xtype : 'supercombotree',
									fieldLabel : '预算单位',
									name : 'en_code',
									"table" : "ele_enterprise",
									"displayField" : "chr_name",
									"valueField" : "chr_code",
									"parentField" : "parent_id",
									"idField" : "chr_id",
									"leafField" : "is_leaf",
									"selectMode" : "leaf",
									"multiSelect" : true,
									"rootValue" : "all",
									joinCode : true
								}, {
									fieldLabel : '项目名称',
									name : '@bis_name'
								}/*
									 * { xtype : 'supercombotree', fieldLabel :
									 * '项目名称', name : 'bis_code', "table" :
									 * "ELE_BUDGET_ITEM_SUMMARY", "displayField" :
									 * "chr_name", "valueField" : "chr_code",
									 * "parentField" : "parent_id", "idField" :
									 * "chr_id", "leafField" : "is_leaf",
									 * "selectMode" : "leaf", "multiSelect" :
									 * true, "rootValue" : "all", joinCode :
									 * true }
									 */, {
									xtype : 'supercombotree',
									fieldLabel : '功能分类',
									name : 'bs_code',
									"table" : "ele_budget_subject",
									"displayField" : "chr_name",
									"valueField" : "chr_code",
									"parentField" : "parent_id",
									"idField" : "chr_id",
									"leafField" : "is_leaf",
									"selectMode" : "leaf",
									"multiSelect" : true,
									"rootValue" : "all",
									joinCode : true
								}, {
									xtype : 'combo',
									fieldLabel : '科目类型',
									name : 'type_id',
									hiddenName : 'type_id',
									triggerAction : 'all',
									mode : 'local',
									editable : false,
									store : [['11', '基金预算支出'], ['22', '一般预算支出']]
								}, {
									xtype : 'radiogroup',
									fieldLabel : '拆分数据',
									name : 'copyid',
									items : [{
												name : 'copyid',
												inputValue : '-1',
												boxLabel : '全部',
												checked : true
											}, {
												name : 'copyid',
												inputValue : '1',
												boxLabel : '是'
											}, {
												name : 'copyid',
												inputValue : '0',
												boxLabel : '否'
											}]
								}]
					}, {
						items : [{
									xtype : 'supercombotree',
									fieldLabel : '业务科室',
									name : 'mb_code',
									"table" : "ele_manage_branch",
									"displayField" : "chr_name",
									"valueField" : "chr_code",
									"parentField" : "parent_id",
									"idField" : "chr_id",
									"leafField" : "is_leaf",
									"selectMode" : "leaf",
									"multiSelect" : true,
									"rootValue" : "all",
									joinCode : true
								}, {
									xtype : 'supercombotree',
									fieldLabel : '项目分类',
									name : 'bi_code',
									"table" : "ELE_BUDGET_ITEM",
									"displayField" : "chr_name",
									"valueField" : "chr_code",
									"parentField" : "parent_id",
									"idField" : "chr_id",
									"leafField" : "is_leaf",
									"selectMode" : "leaf",
									"multiSelect" : true,
									"rootValue" : "all",
									joinCode : true
								}, {
									xtype : 'supercombotree',
									fieldLabel : '指标类型',
									name : 'bp_code',
									"table" : "ELE_BUDGET_PURPOSE",
									"displayField" : "chr_name",
									"valueField" : "chr_code",
									"parentField" : "parent_id",
									"idField" : "chr_id",
									"leafField" : "is_leaf",
									"selectMode" : "leaf",
									"multiSelect" : true,
									"rootValue" : "all",
									joinCode : true
								}, {
									xtype : 'supercombotree',
									fieldLabel : '预算来源性质',
									name : 'hold1_code',
									"table" : "ele_hold1",
									"displayField" : "chr_name",
									"valueField" : "chr_code",
									"parentField" : "parent_id",
									"idField" : "chr_id",
									"leafField" : "is_leaf",
									"selectMode" : "leaf",
									"multiSelect" : true,
									"rootValue" : "all",
									joinCode : true
								}, {
									xtype : 'numberfield',
									name : 'budget_money',
									fieldLabel : '指标金额'
								}]
					}]
		});
	},
	initGrid : function() {
		var me = this;
		var pageSize = 100;
		var store = new Ext.data.JsonStore({
			fields : ['b_vou_id', 'en_id', 'en_code', 'en_name', 'bs_id',
					'bs_code', 'bs_name', 'mb_id', 'mb_code', 'mb_name',
					'mk_id', 'mk_code', 'mk_name', 'bl_id', 'bl_code',
					'bl_name', 'hold1_id', 'hold1_code', 'hold1_name',
					'bis_id', 'bis_code', 'bis_name', 'bi_id', 'bi_code',
					'bi_name', 'pk_id', 'pk_code', 'pk_name', 'hold2_id',
					'hold2_code', 'hold2_name', 'hold3_id', 'hold3_code',
					'hold3_name', 'hold15_id', 'hold15_code', 'hold15_name',
					'bp_id', 'bp_code', 'bp_name', 'file_name', 'sm_name',
					'remark', 'title', 'budgettype_code', 'type_id',
					'adjust_way', 'is_valid', 'is_end', 'budget_groupid',
					'ba_code', 'ba_name', 'toctrlid', 'fromctrlid',
					'budget_money', 'show_money', 'minus_money', 'create_date',
					'copyid', 'subitems', {
						name : 'en_name_show',
						mapping : 'en_name',
						convert : function(v, r) {
							if (!v) {
								return '';
							}
							return r.en_code + v;
						}
					}, {
						name : 'bs_name_show',
						mapping : 'bs_name',
						convert : function(v, r) {
							if (!v) {
								return '';
							}
							return r.bs_code + v;
						}
					}, {
						name : 'bi_name_show',
						mapping : 'bi_name',
						convert : function(v, r) {
							if (!v) {
								return '';
							}
							return r.bi_code + v;
						}
					}],
			url : My.url('/system/common/queryBySql.do'),
			baseParams : {
				start : 0,
				limit : pageSize,
				datacols : 'show_money',
				sql : "SELECT * FROM ( SELECT A.*, ROWNUM RN FROM (select B_VOU_ID,EN_ID,EN_CODE,EN_NAME,BS_ID,BS_CODE,BS_NAME,MB_ID,MB_CODE,MB_NAME,MK_ID,MK_CODE,MK_NAME,BL_ID,BL_CODE,BL_NAME,HOLD1_ID,HOLD1_CODE,HOLD1_NAME,BIS_ID,BIS_CODE,BIS_NAME,BI_ID,BI_CODE,BI_NAME,PK_ID,PK_CODE,PK_NAME,HOLD2_ID,HOLD2_CODE,HOLD2_NAME,HOLD3_ID,HOLD3_CODE,HOLD3_NAME,HOLD15_ID,HOLD15_CODE,HOLD15_NAME,BP_ID,BP_CODE,BP_NAME,FILE_NAME,SM_NAME,REMARK,TITLE,BUDGETTYPE_CODE,TYPE_ID,ADJUST_WAY,IS_VALID,IS_END,BUDGET_GROUPID,BA_CODE,BA_NAME,TOCTRLID,FROMCTRLID,BUDGET_MONEY-MINUS_MONEY SHOW_MONEY, BUDGET_MONEY,DELETED,CREATE_DATE,COPYID,MINUS_MONEY,(select count(1) from ele_budget_syncdata where deleted=0 and copyid=t.b_vou_id) subitems from ele_budget_syncdata t where DELETED=0 and BUDGET_MONEY-MINUS_MONEY>0 order by en_code,bs_code,budget_money-minus_money) A WHERE ROWNUM <= #{start}+#{limit} ) WHERE RN >= #{start}+1 ",
				totalSql : "select nvl(sum(budget_money-minus_money),0) SHOW_MONEY from ele_budget_syncdata where deleted=0",
				countSql : "select count(1) from ele_budget_syncdata where DELETED=0 and BUDGET_MONEY-MINUS_MONEY>0"
			},
			root : 'data',
			autoLoad : true,
			applySort : function() {
				if (this.sortInfo && !this.remoteSort) {
					var s = this.sortInfo, f = s.field;
					var st = this.fields.get(f).sortType;
					var fn = function(r1, r2) {
						var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
						if (!r1.get('en_name')) {
							return 0;
						}
						// 中文排序不正确解决
						if (typeof(v1) == "string") {
							return v1.localeCompare(v2);
						}
						return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
					};
					this.data.sort(s.direction, fn);
					if (this.snapshot && this.snapshot != this.data) {
						this.snapshot.sort(s.direction, fn);
					}
				}
			}
		});
		var pagingToolbar = new Ext.PagingToolbar({
					style : 'border-left:0;border-bottom:0;border-right:0;',
					store : store,
					pageSize : pageSize,
					displayInfo : true,
					updateInfo : function() {
						if (this.displayItem) {
							var count = this.store.getCount();
							var msg = count == 0 ? this.emptyMsg : String
									.format(this.displayMsg, this.cursor + 1,
											this.cursor + count - 1, this.store
													.getTotalCount());
							this.displayItem.setText(msg);
						}
					},
					items : ['-', '每页显示：', {
						xtype : 'combo',
						editable : false,
						width : 60,
						triggerAction : 'all',
						mode : 'local',
						twinTrigger : false,
						store : [[50, '50'], [100, '100'], [200, '200'],
								[500, '500'], [999999999, '全部']],
						value : 100,
						listeners : {
							select : function(t, rec) {
								pageSize = t.getValue() || 100;
								pagingToolbar.pageSize = pageSize;
								store.baseParams.limit = pageSize;
								store.baseParams.start = 0;
								store.load();
							}
						}
					}, '条']
				});
		this.grid = new Ext.grid.GridPanel({
			region : 'center',
			loadMask : true,
			enableHdMenu : false,
			querySql : "",
			viewConfig : {
				getRowClass : function(record, rowIndex, rowParams, store) {
					if (record.data.copyid) {
						return '" style="color:green;"';
					}
					return '';
				}
			},
			bbar : pagingToolbar,
			getRecord : function() {
				return me.grid.getSelectionModel().getSelected();
			},
			store : store,
			sm : new Ext.grid.RowSelectionModel({
						listeners : {
							rowselect : function(t, i, r) {
								try {
									var rec = me.grid.getStore().getAt(i);
									var toolbar = me.grid.getTopToolbar();
									var _update = toolbar
											.getComponent('_update');
									var _delete = toolbar
											.getComponent('_delete');
									if (!rec.data.en_name) {
										_update.setDisabled(true);
										_delete.setDisabled(true);
									} else {
										_update.setDisabled(false);
										_delete.setDisabled(false);
									}
								} catch (e) {
								}
							}
						}
					}),
			cm : new Ext.grid.ColumnModel({
				defaults : {
					align : 'center',
					sortable : true,
					width : 150,
					renderer : function(v, m) {
						m.attr = "style='text-align:left;' title='" + v + "'";
						return v;
					}
				},
				columns : [new Ext.grid.RowNumberer(), {
							dataIndex : 'en_name_show',
							width : 250,
							header : '单位名称'
						}, {
							dataIndex : 'show_money',
							header : '指标金额',
							renderer : function(v, m, r) {
								v = Ext.util.Format.number(v, '0,0.00');
								m.attr = "style='text-align:right;'";
								if (r.data.copyid) {
									v = '(拆分)' + v;
									m.attr = "style='text-align:right;color:green;'";
								}
								return v;
							}
						}, {
							dataIndex : 'bs_name_show',
							header : '功能分类',
							width : 180
						}, {
							dataIndex : 'bi_name_show',
							header : '项目分类'
						}, {
							dataIndex : 'remark',
							header : '自定义编号'
						}, {
							dataIndex : 'sm_name',
							header : '摘要',
							width : 180
						}, {
							dataIndex : 'mb_name',
							header : '业务科室'
						}, {
							dataIndex : 'mk_name',
							header : '资金性质'
						}, {
							dataIndex : 'bl_name',
							header : '预算来源'
						}, {
							dataIndex : 'hold1_name',
							header : '预算来源性质'
						}, {
							dataIndex : 'bis_name',
							header : '项目名称'
						}, {
							dataIndex : 'pk_name',
							header : '支付方式'
						}, {
							dataIndex : 'hold2_name',
							header : '政府支出管理结构'
						}, {
							dataIndex : 'hold3_name',
							header : '编制类型'
						}, {
							dataIndex : 'hold15_name',
							header : '涉农标识'
						}, {
							dataIndex : 'bp_name',
							header : '指标类型'
						}, {
							dataIndex : 'file_name',
							header : '指标文号'
						}, {
							dataIndex : 'title',
							header : '指标标题'
						}, {
							dataIndex : 'adjust_way',
							header : '是否可拆分',
							renderer : function(v, m, r) {
								if (v == '1') {
									m.attr = 'style="color:green;"';
									return '是';
								}
								m.attr = 'style="color:red;"';
								return '否';
							}
						}]
			}),
			bodyStyle : 'border-left:0;border-right:0;',
			tbar : new Ext.Toolbar({
						style : 'border-left:0;border-bottom:0;',
						items : [{
									text : '查询',
									iconCls : 'icon-search',
									handler : function() {
										me.search();
									}
								}, '-', {
									text : '修改',
									iconCls : 'icon-update',
									itemId : '_update',
									handler : function() {
										me.update();
									}
								}, {
									text : '删除',
									itemId : '_delete',
									iconCls : 'icon-delete',
									handler : function() {
										me.del();
									}
								}, {
									text : '拆分',
									itemId : '_chaifen',
									iconCls : 'icon-copy',
									handler : function() {
										me.chaifen();
									}
								}, '-', {
									text : '同步数据',
									iconCls : 'icon-sync',
									handler : function() {
										me.sync();
									}
								}, {
									text : '导出Excel',
									iconCls : 'icon-excel',
									handler : function() {
										me.exportExcel();
									}
								}]
					}),
			listeners : {
				rowdblclick : function(t) {
					me.update();
				}
			}
		});
	}
});

Ext.onReady(function() {
			new Ext.Viewport({
						layout : 'fit',
						items : [new Buis()]
					});
		});